@extends('linfeng.home.logon')
@section('titl','登入')
@section('login-content')
    <div id="container" class="content login content-member">
        <div class="login-bg">
            <img src="{{asset('image/home/login-bg.jpg')}}" alt="">
        </div>
        <div class="login-box">
            <h2>登录人生书屋</h2> &nbsp;<a href="https://graph.qq.com/oauth2.0/authorize?response_type=code&client_id=101392477&redirect_uri=http://www.tzvk.vip/login&scope=人生书屋" style="position: absolute;top: 20px;left: 186px;"><img src="{{asset('image/home/qq.jpg')}}" alt="">qq登入</a>
            <div class="bon"><button class="btn btn-default gobun" id="duanxing">短信登入</button><button class="btn btn-default gobun" id="zhanghu">账户登入</button></div>
            {{--//普通登入--}}
            <div style="display:none" id="zhanghudiv">
                <form action="{{url('home/login/zhanghu')}}" method="POST" class="vern">
                    {{csrf_field()}}
                    <span class="error"></span>
                    <label for="username" class="black">昵称</label>
                    <input class="input-txt input-sp vern" type="text"  data-type="username" name="nickname" placeholder="昵称">
                    @if($errors)
                        <span class="first">{{$errors->first('nickname')}}</span>
                    @endif
                    <div class="kong" style="height: 10px;"></div>
                    <label for="password" class="black">密码</label>
                    <input class="input-txt input-sp vern" type="password" name="password" data-type="password" placeholder="请输入密码">
                    @if($errors)
                        <span class="first">{{$errors->first('password')}}</span>
                    @endif
                    <div class="kong" style="height: 50px;"></div>
                    <div class="login-mode">
                        <input class="btn btn-info change-but" style="width:140px" type="submit" value="登 录">
                        <a class="reg-link blue-s" href="{{url('home/logon')}}" style="float:right">立即注册</a>
                        <div class="clearfix"  style="margin-bottom:20px"></div>
                    </div>
                </form>
            </div>

            <script>
                $(function(){
                    $('#duanxing').click(function () {
                        $('#zhanghudiv').css('display','none');
                        $('#duanxingdiv').css('display','inline');
                    })
                    $('#zhanghu').click(function () {
                        $('#zhanghudiv').css('display','inline');
                        $('#duanxingdiv').css('display','none');
                    })
                })
            </script>

            {{--//短信登入--}}
            <div style="display:inline" id="duanxingdiv">
            <form action="" method="POST" class="vern">
                {{csrf_field()}}
                <span class="error"></span>
                <label for="username" class="black">手机号</label>
                <input class="input-txt input-sp vern" type="text" id="tel" data-type="username" name="tel" placeholder="手机号登录">
                @if($errors)
                    <span class="first">{{$errors->first('tel')}}</span>
                @endif
                <div>
                    <label for="username" class="black">短信验证码</label>
                    <div class="verification-code">
                        <input class="input-txts input-ss vern" name="code" id="" type="text" data-type="securityCode" placeholder="手机短信验证码">
                        <input type="button"  class="btn btn-default" id="goSMS" value="获取验证码">
                        @if($errors)
                            <span class="first">{{$errors->first('code')}}</span>
                        @endif
                        @if($docode)
                            <span class="first">{{$docode}}</span>
                        @endif
                        <div class="clearfix"></div>
                    </div>
                </div>
                <label for="password" class="black">密码</label>
                <input class="input-txt input-sp vern" type="password" name="password" data-type="password" placeholder="请输入密码">
                @if($errors)
                    <span class="first">{{$errors->first('password')}}</span>
                @endif
                <div class="login-mode">
                    <input class="btn btn-info change-but" style="width:140px" type="submit" value="登 录">
                    <a class="reg-link blue-s" href="{{url('home/logon')}}" style="float:right">立即注册</a>
                    <div class="clearfix"  style="margin-bottom:20px"></div>
                </div>
            </form>
            </div>
        </div>
    </div>
    {{--ajax请求短信验证码--}}
    <script>
        $(function(){
            $('#goSMS').click(function(){

                $tel=$('#tel').val()

                $.ajax({
                    url:"{{url('home/sendSMS')}}",
                    type:'get',
                    data:'tel='+$tel,
                    success:function (data) {
//                        alert(data)
                        if (data==222){
                            alert('此号码未注册')
                        }else{
                            alert('短信已发送')
                        }
                        $sum=data;
                        $str=$sum.substr(-1);

                    },
//                    headers: {
//                        'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
//                    },
//                    13738544637   18201793674
                    error:function(){
                        alert('错误');
                    },
                    dataType:'text'
                })
            })
        })
    </script>
@endsection